import 'package:flutter/material.dart';
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
import 'package:ok_ui/flutter_ok_ui.dart';

import '../../repo/color_repo.dart';

void showColorPicker(BuildContext context) {
  showDialog(
    context: context,
    builder: (ctx) {
      return SafeArea(
        child: Center(
          child: Column(
            children: <Widget>[
              Container(
                width: MediaQuery.of(context).size.width - 100,
                child: StreamBuilder<MaterialColor>(
                    initialData: ColorRepo().themeColor,
                    stream: ColorRepo().themeColorStream,
                    builder: (context, snapshot) {
                      return MaterialColorPicker(
                        onMainColorChange: (color) {
                          ColorRepo().themeColor = color;
                        },
                        selectedColor: snapshot.data,
                      );
                    }),
                color: Colors.white,
              ),
              OKTextButton(
//                  margin: const EdgeInsets.symmetric(horizontal: 16.0),
                width: MediaQuery.of(context).size.width - 100,
                text: "确定",
                onTap: () => Navigator.pop(context),
              ),
            ],
            mainAxisSize: MainAxisSize.min,
          ),
        ),
      );
    },
  );
}
